//用来专门设置动态路由
import equest from "@/utils/equest"
import router from "@/router/index"
import Layout from "@/layout/Layout"
import Home from "@/views/Home";

    
export  function activRouter(){
    const userStr = sessionStorage.getItem("user")
    if (userStr) {
        const user = JSON.parse(userStr)
        let root ={
            path: '/home',
            name: '导航2',
            component: Home,
            children:[]
        }
        user.data.permissions.forEach(p =>{
            let obj = {
                path: p.path,
                name: p.name,
                component: () => import("@/views" + p.path)
            };
            root.children.push(obj)
        })
        if (router) {
            console.log(root)
            router.addRoute(root)
        }
    }

}

